package com.ijunfu.lambda._03_sort;

import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;

/**
 *
 * @Title  : 集合排序
 * @Author : ijunfu <ijunfu@163.com>
 * @Date   : 2023/11/18 13:41
 * @Version: 1.0
 * @Motto  : 世界很大 世界很小
 *
 */
public class Main {

    public static void main(String[] args) {

        List<String> fruits = Arrays.asList("banana", "apple", "pear", "grapefruit", "orange");

        fruits.stream().forEach(System.out::println);
        System.out.println("=================================");
/*
        Collections.sort(fruits, new Comparator<String>() {
            @Override
            public int compare(String o1, String o2) {
                return o1.compareTo(o2);
            }
        });

        fruits.stream().forEach(System.out::println);
        System.out.println("=================================");
*/

        Collections.sort(fruits, (o1, o2)-> o1.compareTo(o2));

        fruits.stream().forEach(System.out::println);
        System.out.println("=================================");
    }
}
